﻿<?php
	header("Content-type: text/html;charset=utf8");
	require_once("../db/dbclass.php");
	require_once("../model/userinfo.php");
	require_once("../utils/common.php");
	require_once("../utils/config.php");
	$myDb=&DbController::getInstance();
	$result_obj = new UserInfo();
	$type=$_POST['type'];
	switch($type){
		case "1":
				$user_id=$_POST['param'];
				break;
		case "2":
				$user_name=$_POST['param'];
				$param="select user_id from yj_user_info where user_name ='".$user_name."'";
				$result = $myDb->exec_query($param);
				if($result == TRUE){
					while($row = mysqli_fetch_array($result,MYSQL_ASSOC)){
						$user_id=$row['user_id'];
					}
				}
				break;
		case "3":
				$user_email=$_POST['param'];
				$param="select user_id from yj_user_info where user_email ='".$user_email."'";
				$result = $myDb->exec_query($param);
				if($result == TRUE){
					while($row = mysqli_fetch_array($result,MYSQL_ASSOC)){
						$user_id=$row['user_id'];
					}
				}
				break;
	}
	$param="select * from yj_user_info where user_id ='".$user_id."'";
	$result=$myDb->exec_query($param);
	if($result==TRUE){
		$row = mysqli_fetch_array($result,MYSQL_ASSOC);
		$result_obj->id=$row['user_id'];
		$result_obj->username = $row['user_name'];
  		$result_obj->email = $row['user_email'];
  		$result_obj->work=$row['user_work'];
		$result_obj->sex = $row['user_sex'];
  		$result_obj->birth = $row['user_birth'];
  		$result_obj->nickname=$row['user_nickname'];
  		$result_obj->location=$row['user_location'];
		$result_obj->img_url =$result_obj->img_url.URL.substr($row['user_photo'],2);
  		$result_obj->usersign = $row['user_sign'];
  		$result_obj->follow_num = $row['follow_num'];
  		$result_obj->focus_num = $row['focus_num'];
  		$result_obj->result="success";
	}
	else{
		$result_obj->result="failure";
	}
	$result_json = json_encode($result_obj);
	echo $result_json;
?>